var patten_phone = /^1(30|31|32|33|34|35|36|37|38|39|45|47|50|51|52|53|55|56|57|58|59|70|71|77|73|76|78|80|81|82|83|84|85|86|87|88|89)\d{8}$/g

//判断数组是否包含给定字符串
function isContain(arr, str) {
  for (var i = 0; i < arr.length; i++) {
    if (arr[i] == str) {
      return true
    }
  }
  return false
}
// 去除数据的前后空格
function trim(str) {
  if (!str || str.length == 0) return null
  var result = str.replace(/(^\s*)|(\s*$)/g, "")
  return result
}

// 检查手机号码是否合格
function checkCellphone(str) {
  var result = trim(str)
  if (!result || result.length != 11 || result.indexOf('1') != 0) {
    return false
  }
  var matcher = result.match(patten_phone)
  if (matcher) {
    return true
  }
  return false
}
module.exports={
  isContain: isContain,
  checkCellphone: checkCellphone,
}